//---------------------------------------------------------------------------
//
// Name:        DescomprimirFrame.cpp
// Author:      Fernandez Vera Ezequiel, Manzanel Juan Manuel
// Created:     21/02/2009 03:17:44 p.m.
// Description: DescomprimirFrame class implementation
//
//---------------------------------------------------------------------------

#include "DescomprimirFrame.h"

//Do not add custom headers between
//Header Include Start and Header Include End
//wxDev-C++ designer will remove them
////Header Include Start
////Header Include End

//----------------------------------------------------------------------------
// DescomprimirFrame
//----------------------------------------------------------------------------
//Add Custom Events only in the appropriate block.
//Code added in other places will be removed by wxDev-C++
////Event Table Start
BEGIN_EVENT_TABLE(DescomprimirFrame,wxFrame)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(DescomprimirFrame::OnClose)
	EVT_BUTTON(ID_BOTONDESCOMPRIMIR,DescomprimirFrame::botonDescomprimirClick)
END_EVENT_TABLE()
////Event Table End

DescomprimirFrame::DescomprimirFrame(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	CreateGUIControls();
	if(dialogoAbrir->ShowModal() == wxID_OK)
        comprimido = dialogoAbrir->GetPath();
    compresor = new Compresor();
    this->SetBackgroundColour(wxColour(_("white")));
}

DescomprimirFrame::~DescomprimirFrame()
{
}

void DescomprimirFrame::CreateGUIControls()
{
	//Do not add custom code between
	//GUI Items Creation Start and GUI Items Creation End
	//wxDev-C++ designer will remove them.
	//Add the custom code before or after the blocks
	////GUI Items Creation Start

	SetTitle(wxT("DescomprimirFrame"));
	SetIcon(wxNullIcon);
	SetSize(8,8,320,334);
	Center();
	

	dialogoGuardar =  new wxFileDialog(this, wxT("Elija donde desea reconstruir la imagen"), wxT(""), wxT(""), wxT("*.*"), wxSAVE);

	dialogoAbrir =  new wxFileDialog(this, wxT("Eliga una imagen comprimida"), wxT(""), wxT(""), wxT("*.*"), wxOPEN);

	botonDescomprimir = new wxButton(this, ID_BOTONDESCOMPRIMIR, wxT("Descomprimir!"), wxPoint(65,97), wxSize(185,79), 0, wxDefaultValidator, wxT("botonDescomprimir"));
	botonDescomprimir->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
	////GUI Items Creation End
}

void DescomprimirFrame::OnClose(wxCloseEvent& event)
{
	Destroy();
}

/*
 * botonDescomprimirClick
 */
void DescomprimirFrame::botonDescomprimirClick(wxCommandEvent& event)
{
	if (dialogoGuardar->ShowModal() == wxID_OK) {
       imagen = dialogoGuardar->GetPath();
       compresor->Descomprimir(comprimido.ToAscii(),imagen.ToAscii());
    }
	Destroy();
}
